$(function () {
    
    console.log('dom已经准备妥当');

    $('#btnAdd').click(function () {
        window.location.href = `/Account/CreateOrEdit`
    })

    $('#btnSave').click(function () {
        let Id = $('[name=id]').val();
        let ProductName = $('[name=productName]').val();
        let Supplier = $('[name=supplier]').val();
        let Price = $('[name=price]').val();
        let Stock = $('[name=stock]').val();
        let Remarks = $('[name=remarks]').val();
        let obj =
        {
            Id,
            ProductName,
            Supplier,
            Price,
            Stock,
            Remarks
        }
        console.log(obj);
        // $.post('/Account/save', obj, function (res) {
        //     console.log(res);
        //     window.location.href = `/Account/Index`
        // })
        $.post('/Account/save', obj, function () {
            alert('保存成功！')
            window.location.href = `/Account/index`
          })
    })

})

$('#btnCancel').click(function () {
    window.location.href = `/Account/Index`
})
function btnEdit(id) {
    window.location.href = `/Account/CreateOrEdit/${id}`
}
function btnDel(id) {
    var obj={
        id
    }
    $.post('/Account/Delete', obj, function () {
        alert('删除成功！')
        window.location.href = `/Account/index`
      })
}